package cn.eaay.stock.service.impl;

import cn.eaay.stock.common.enums.ResponseCode;
import cn.eaay.stock.mapper.StockBlockRtInfoMapper;
import cn.eaay.stock.service.StockBlockRtInfoService;
import cn.eaay.stock.vo.resp.R;
import cn.eaay.stock.vo.stock.StockBlockInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Service("stockBlockRtInfoService")
public class StockBlockRtInfoServiceImpl implements StockBlockRtInfoService {

    @Resource
    private StockBlockRtInfoMapper stockBlockRtInfoMapper;

    /**
     * 获取国内大盘板块实时详情
     *
     * @return {@link R<List<StockBlockInfoVo>> 大盘板块详情列表}
     */
    @Override
    public R<List<StockBlockInfoVo>> getSectorAllLimit() {
        List<StockBlockInfoVo> infos = stockBlockRtInfoMapper.getSectorAllLimit();
        if (CollectionUtils.isEmpty(infos)) {
            return R.error(ResponseCode.ERROR.getMessage());
        }
        return R.ok(infos);
    }
}
